<template>
	<view class="content">
		<view class="padding">
			<view class="flexbetween padding ffffff border_2">
				<view class="yuan">原密码</view>
				<view class="">
					<input type="text" v-model="password" style="text-align: right;" placeholder="请输入原密码">
				</view>
			</view>
			<view class="flexbetween padding ffffff border_2" style="margin-top: 30rpx;">
				<view class="yuan">新密码</view>
				<view class="">
					<input type="text" v-model="newpassword" style="text-align: right;" placeholder="请输入新密码">
				</view>
			</view>
			<view class="flexbetween padding ffffff border_2" style="margin-top: 30rpx;">
				<view class="yuan">确认新密码</view>
				<view class="">
					<input type="text" v-model="confirmNewpassword" style="text-align: right;" placeholder="请再次输入新密码">
				</view>
			</view>
		</view>
	 
		<view class="ljbd">
			<view class="bigbtn" @click="toout">确认修改</view>
		</view>
		<u-modal :show="show" :title="title" showCancelButton="true" confirmColor="RGBA(212, 139, 57, 1)" @confirm="confirm" @cancel="cancel"></u-modal>
		<!-- <u-modal :show="loshow" :title="lotitle" showCancelButton="true" confirmColor="RGBA(212, 139, 57, 1)" @cancel="locancel" @confirm="loconfirm" confirmText="去登录"></u-modal> -->
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show: false,
				title: '您确定要修改吗？',
				// loshow: false, //登录弹窗
				// lotitle: '请登录后再查看!',
				password:"",
				newpassword:"",
				confirmNewpassword:"",
			}
		},
		methods: {
			// locancel() {
			// 	this.loshow = false;
			// },
			// loconfirm() {
			// 	this.loshow = false;
			// 	uni.navigateTo({
			// 		url: '/pages/login/login'
			// 	})
			// },
			confirm() {
				let _this = this;
				if(this.confirmNewpassword!=this.newpassword){
					httpRequest.toast("两次密码输入不一致！")
					this.show=false
					return false
				}
				httpRequest.request('/api/user/changepwd', 'GET', {
					password: _this.password,
					newpassword: _this.newpassword,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						this.show = false;
						httpRequest.toast(res.msg)
						setTimeout(()=>{
							uni.navigateBack(1);
						},500)
					}else if(res.code==0){
						httpRequest.toast(res.msg)
						this.show=false
					}else{
						httpRequest.toast(res.msg)
					}
				}).catch(err=>{
					httpRequest.toast(err.msg)
				})
			},
			we() {
				uni.navigateTo({
					url: "/pages_my/guanyuwm"
				})
			},
			cancel() {
				this.show = false;
			},
			toout() {
				// let _this=this
				// if (!uni.getStorageSync('token')) {
				// 	_this.loshow = true;
				// 	return
				// }
				this.show = true;
			},
		}
	}
</script>

<style lang="scss">
	.yuan{
		font-size: 30rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}
	.ljbd{
		 position: fixed;
		bottom: 50rpx;
		left: 30rpx;
		right: 30rpx;
	}
	.icons {
		width: 16rpx;
		height: 28rpx;
		background-repeat: no-repeat;
	}

	.bigbtn {
		background-color: RGBA(212, 139, 57, 1);
		border-radius: 41rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		height: 82rpx;
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
	}
</style>